<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      
    </style>
</head>
<body>
    <div id="app">
        <form action="">
            姓名：<input type="text" v-model='name'>
            性别：<input type="text" v-model='sex'>
            手机号：<input type="text" v-model='tel'>
            <input type="submit" value="提交" @click.prevent="submit()">
        </form>
        <table border="1" width="300" height="30">
            <thead>
                <tr>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>手机号</th>
                </tr>
            </thead>
            <tbody>
                <tr v-for="item,index in userList" :key="item.tel">
                    <td>{{item.name}}</td>
                    <td>{{item.sex}}</td>
                    <td>{{item.tel}}</td>
                </tr>
            </tbody>
        </table>

    </div>
    
    <script src="../js/vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                name:'',
                sex:'',
                tel:'',
                userList:[

                ]
            },
            methods: {
                submit(){
                    if(this.name==''&&this.sex==''&&this.tel==''){
                        alert('不得为空')
                        return;
                    }
                    this.userList.push({
                        name:this.name,
                        sex:this.sex,
                        tel:this.tel
                    })
                }
            },
        })
    </script>
</body>
</html>